<?php

if (!defined('BASEPATH'))
  exit('No direct script access allowed');


class Comment extends CI_Model {

	var $_table_name = 'comment';
    var $_table_user = 'user';

	public function __construct() {
    	$this->load->database();
  	}

  	public function get_num($list_id){

  		$this->db->select('*');
  		$this->db->from($this->_table_name);

  		$this->db->where('list_id', $list_id);
  		$query = $this->db->get();

      return $query->num_rows();
  	}

    public function get_comment_list($list_id){

        $this->db->select('*');
        $this->db->from($this->_table_name . ' AS c');
        $this->db->join($this->_table_user . ' AS u', 'c.user_id = u.user_id','left');
        $this->db->where('c.list_id', $list_id);
        $query = $this->db->get();

        return $query->result_array();
    }

    public function insert($insertData){

        $this->db->insert($this->_table_name, $insertData);
        return $this->db->insert_id();
    }

}

